<?php
session_start ();
include ("conn/conn.php");
error_reporting(0);
if ($_SESSION ["username"] == "") {
	echo "<script>alert('请先登录后预定');history.back();</script>";
	exit ();
}
$id = strval ( $_GET ["id"] );
$sql = mysqli_query ( $conn, "select * from tb_shangpin where id='" . $id . "'" );
$info = mysqli_fetch_array ( $sql );
if ($info ["shuliang"] <= 0) {
	echo "<script>alert('预定结束，请下次早些来');history.back();</script>";
	exit ();
}
$array = explode ( "@", $_SESSION ["producelist"] );
for($i = 0; $i < count ( $array ) - 1; $i ++) {
	if ($array [$i] == $id) {
		echo "<script>alert('这房品已经在我的预定清单中');history.back();</script>";
		exit ();
	}
}
$_SESSION ["producelist"] = $_SESSION ["producelist"] . $id . "@";
$_SESSION ["quatity"] = $_SESSION ["quatity"] . "1@";
header ( "location:gouwu1.php" );
?> 